package com.sendables;

import java.nio.ByteBuffer;

public class Number extends Sendable {
	private int	nbr;

	public Number(int nbr)
	{
		this.nbr = nbr;
	}

	public static Number parse(byte[] b, int[] offset)
	{
		int nbr = ByteBuffer.wrap(b, offset[0], b.length - offset[0]).getInt();
		offset[0] += 4;
		return new Number(nbr);
	}

	public void writeByteRepresentation(byte[] b, int[] offset)
	{
		ByteBuffer.wrap(b, offset[0], b.length - offset[0]).putInt(nbr);
		offset[0] += 4;
	}

	@Override
	public int getAlloc()
	{
		return 4;
	}

	public int getContent()
	{
		return nbr;
	}

	public String toString()
	{
		return getClass().getCanonicalName() + "[nbr=" + nbr + "]";
	}

}
